import commands

def write_data(filename, data):
    fo = open(filename, 'a')
    fo.write('\n' + data)
    fo.close()



if __name__ == '__main__':
    filename = 'normal_dataqqqq'
    cmd = 'l2ping -c 10 48:2C:A0:0F:1F:AD'
    count = 0
    while count < 600:
        return_code, output = commands.getstatusoutput(cmd)
        print count
        ol = output.split('\n')
        ln_data = ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0']
        i = 0
        for info in ol:
            if 'time' in info and 'bytes' in info:
                t = info.split(' ')[7]
                nt = t[:len(t)-2]
                # print nt
                # if float(nt) > 1000:
                #     continue
                ln_data[i] = str(nt)
                i = i + 1
        wdata = ''
        for nd in ln_data:
            if wdata == '':
                wdata = nd
            else:
                wdata = wdata + ' ' + nd
        write_data(filename, wdata)
        count = count + 1